package com.twu.biblioteca.library;

import com.twu.biblioteca.Persistence.UserRepository;
import com.twu.biblioteca.library.items.User;

/**
 * Created by aruna on 28/4/14.
 */
public class UserLoginController {
    public static boolean login(String LibraryNumber,String password)
    {
        User user= UserRepository.getUserByLibraryNumber(LibraryNumber);
        if(user != null) {
            if (user.getUserCredential().getPassword().contentEquals(password)){

                user.setLoggedIn(true);
                return true;

            }
            user.setLoggedIn(false);

        }
        return false;
    }
    public static boolean logout(String LibraryNumber,String password)
    {
        User user= UserRepository.getUserByLibraryNumber(LibraryNumber);
        if(user != null) {
            if (user.getUserCredential().getPassword().contentEquals(password)){
                user.setLoggedIn(false);
                return true;

            }
        }
        return false;
    }
}
